package com.yanqu.road.server.cmd.unioncampwar.cross;

import com.yanqu.road.entity.enums.eLogMoneyType;
import com.yanqu.road.entity.enums.eMailType;
import com.yanqu.road.entity.player.UserInfo;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.pb.unionCampWar.UnionCampWar;
import com.yanqu.road.server.GameServer;
import com.yanqu.road.server.cmd.base.AbstractCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.gameplayer.module.player.CurrencyModule;
import com.yanqu.road.server.gameplayer.module.player.PreReduceModule;
import com.yanqu.road.server.logic.mail.MailManager;
import com.yanqu.road.server.manger.ConfigMgr;
import com.yanqu.road.server.manger.MultipleLanguageMgr;
import com.yanqu.road.server.manger.ServerLanguageMgr;
import com.yanqu.road.server.manger.mail.ServerMailMgr;
import com.yanqu.road.server.manger.player.UserMgr;
import com.yanqu.road.server.protocol.ClientProtocol;
import com.yanqu.road.server.protocol.GameErrorCode;
import com.yanqu.road.server.protocol.GameProtocol;
import com.yanqu.road.utils.property.Property;

import java.text.MessageFormat;


@Cmd(code = GameProtocol.S_UNION_CAMP_WAR_AUTO_SEND_RANK_REWARD, desc = "排行奖励自动发奖")
public class CrossUnionCampAutoSendRankRewardCmd extends AbstractCommand {

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        return true;
    }

    @Override
    public void execute(GamePlayer player, YanQuMessage packet) throws Exception {
        UnionCampWar.CrossUnionCampWarAutoSendRewardMsg respMsg = UnionCampWar.CrossUnionCampWarAutoSendRewardMsg.parseFrom(packet.getBytes());
        for (UnionCampWar.UnionCampWarSendRewardTemp rewardTemp : respMsg.getUserInfosList()) {
            long userId = rewardTemp.getUserId();
            UserInfo userInfo = UserMgr.getUserInfo(userId);
            if (null == userInfo) {
                continue;
            }
            String language = userInfo.getLanguage();
            String rewards = rewardTemp.getRewards();

            String mailTitle = MultipleLanguageMgr.getContent(MailManager.SHANGBANG_RANK_REWARD_TITLE,
                    language);
            String mailContent = MultipleLanguageMgr.getContent(MailManager.SHANGBANG_RANK_REWARD_CONTENT, userInfo.getLanguage());
            MailManager.sendMail(userId, eMailType.SYSTEM.getValue(), rewards, mailContent, mailTitle);
        }
    }

    @Override
    public void sendData(GamePlayer player) {
        if (null == player) {
            return;
        }

    }
}
